package org.xiaoyu.rpc.registry.nacos.support;

/**
 * Created By Have
 * 2021/7/21 21:30
 */
public interface ThrowableConsumer<T> {
    void accept(T t) throws Throwable;

    default void execute(T t) throws RuntimeException {
        try {
            accept(t);
        } catch (Throwable e) {
            throw new RuntimeException(e.getMessage(), e.getCause());
        }
    }

    static <T> void execute(T t, ThrowableConsumer<T> consumer) {
        consumer.execute(t);
    }
}
